package ThreadPoolTest;

import redis.clients.jedis.Jedis;

public class RedisDlqManager {

    private static final String DLQ_KEY = "delKey";
    private final Jedis jedis;
    public RedisDlqManager(String redisHost, int redisPort) {
        this.jedis = new Jedis(redisHost ,redisPort);
    }


    public void addTask(Runnable task){
        jedis.rpush(DLQ_KEY, task.toString());
    }

    public String takeTask(){
        String lpop = jedis.lpop(DLQ_KEY);
        return  lpop;

    }


    public Long size(){
        return jedis.llen(DLQ_KEY);
    }

    public void close(){
        jedis.close();
    }



}
